package org.example.net;

import lombok.SneakyThrows;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * @Auther:Liu
 * @Testname:DemoD2
 * @Date:2025/8/28 10:00
 */
public class DemoD2 {
    @SneakyThrows
    public static void main(String[] args) {
        DatagramSocket datagramSocket = new DatagramSocket(9999);
        byte[] buffer = new byte[1024];
        DatagramPacket datagramPacket = new DatagramPacket(buffer, buffer.length);
        datagramSocket.receive(datagramPacket);
        String s = new String(datagramPacket.getData(), 0, datagramPacket.getLength());
        System.out.println(s);
    }
}
